package howl.Servlets;

import howl.model.Model;
import howl.model.PMF;
import howl.types.*;
import howl.types.query.QueryHelper;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import twitter4j.Twitter;
import twitter4j.TwitterException;

@SuppressWarnings("serial")
public class DataGenerator extends HttpServlet {
	
	protected String getRequestedURL(HttpServletRequest request){
		String file = request.getRequestURI();
		if (request.getQueryString() != null) {
		   file += '?' + request.getQueryString();
		}
		URL reconstructedURL;
		try {
			reconstructedURL = new URL(request.getScheme(),
			                               request.getServerName(),
			                               request.getServerPort(),
			                               file);
			return reconstructedURL.toString();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
	}

	protected String[] subArray(int start, int end, String[] s) {
		String[] ret = new String[end + 1 - start];
		for (int i = 0; i < end + 1 - start; i++) {
			ret[i] = s[start + i];
		}

		return ret;
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
		
			resp.sendError(resp.SC_METHOD_NOT_ALLOWED, "This Page only supports GET");
		
	}
}
